using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using YABlog.BLL;

public partial class AddCategory : System.Web.UI.Page
{
    CategoriesAction cat = new CategoriesAction();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["UserId"] == null)
        {
            Response.Redirect("Login.aspx");
        }
        if (IsPostBack == false)
        {
            if (Request.QueryString["id"] != null)
            {
                if (Request.QueryString["id"] != "0")
                {
                    Label1.Text = Request.QueryString["id"];
                    Label2.Text = cat.GetCategoryNameById(Convert.ToInt32(Request.QueryString["id"]));
                    TextBox1.Text = Label2.Text;
                }
            }
            else
            {
                Response.Redirect("Categories.aspx");
            }
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (TextBox1.Text != "")
        {
            cat.UpdateCategory(Convert.ToInt32(Request.QueryString["id"]), TextBox1.Text);
            Response.Redirect("Categories.aspx");
        }
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        Response.Redirect("Categories.aspx");
    }
}
